from selenium import webdriver
from Base.PublicFunction import OpenBroswer
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class Employ_ManageMent_POM_SHL():
    def __init__(self):
        self.dr=OpenBroswer.openbrower()
        # self.dr.implicitly_wait(20)
        # self.dr.get("http://10.10.10.170:8080/WoniuBoss4.0/")
        self.dr.get('http://10.10.10.171:8080/WoniuBoss4.0/login')
        self.dr.find_element_by_name('userName').send_keys('WNCD000')
        self.dr.find_element_by_name('userPass').send_keys('woniu123')
        self.dr.find_element_by_xpath('/html/body/div[1]/div/div/div[2]/button').click()

    def findElement(self, locator):
        ele = WebDriverWait(self.dr, 10, 0.1).until(EC.presence_of_element_located(locator))
        return ele
    # def findElements(self,locator):
    #     eles= WebDriverWait(self.dr, 10, 0.1).until(EC.presence_of_all_elements_located(locator))
    #     return eles


    # def getusername(self):
    #     locator=(By.NAME,"userName")
    #     ele=self.findElement(locator)
    #     return ele
    #
    # def getpassword(self):
    #     locator=(By.NAME,"userPass")
    #     ele = self.findElement(locator)
    #     return ele
    #
    # def getverifycode(self):
    #     locator = (By.NAME, "checkcode")
    #     ele = self.findElement(locator)
    #     return ele
    #
    #
    # def getlogin(self):
    #     locator = (By.CLASS_NAME, "btn.btn-primary.btn-block.btn-save")
    #     ele = self.findElement(locator)
    #     return ele



    def get_login_text(self):
        locator = (By.CLASS_NAME, "welcome")
        ele = self.findElement(locator)
        return ele


    #登录进去
    def click_jiuye(self):   #点击就业管理
        locator = (By.XPATH,"/html/body/div[4]/div[2]/div[10]/div[1]/a")
        ele = self.findElement(locator)
        return ele

    def click_client(self):    #点击企业客户
        locator = (By.XPATH,"/html/body/div[4]/div[2]/div[10]/div[2]/div/ul/li[4]/a")
        ele = self.findElement(locator)
        return ele

    def click_add_company(self):   #点击新增企业
        locator = (By.CLASS_NAME, "btn.btn-primary.btn-padding.pull-right")
        ele = self.findElement(locator)
        return ele

    def get_company_name(self):   #企业名称
        locator = (By.ID,'newentname')
        ele = self.findElement(locator)
        return ele

    def get_industry(self):   #输入所属行业
        locator = (By.ID, 'newentcate')
        ele = self.findElement(locator)
        return ele

    def get_address(self): #地址
        locator = (By.ID, 'newentaddr')
        ele = self.findElement(locator)
        return ele

    def get_contacts(self):    #联系人
        locator = (By.ID, 'newentheader')
        ele = self.findElement(locator)
        return ele

    def get_phone(self):     #电话号码
        locator = (By.ID, 'newtel')
        ele = self.findElement(locator)
        return ele

    def click_add(self):  #添加的按钮
        locator = (By.XPATH, "/html/body/div[10]/div/div/div[3]/button")
        ele = self.findElement(locator)
        return ele

    def click_insure(self):   #确定
        locator = (By.CLASS_NAME, "btn.btn-primary")
        eles = self.findElements(locator)
        return eles

    def read_table_add_company(self):     #新增完企业的表格    整张表格
        locator = (By.CLASS_NAME, "table.table-hover.table-bordered.table-striped")
        ele = self.findElement(locator)
        return ele

    def serch_table_company(self):     #查询入职企业的表格
        locator = (By.CLASS_NAME, "table.table-hover.table-bordered.table-striped")
        ele = self.findElement(locator)
        return ele

    def serch_table_clientcompany(self):      #企业客户的表格
        locator = (By.CLASS_NAME, "table.table-hover.table-bordered.table-striped")
        ele = self.findElement(locator)
        return ele



    #入职信息
    def click_entry_information(self):
        locator = (By.XPATH,"/html/body/div[4]/div[2]/div[10]/div[2]/div/ul/li[3]/a")
        ele = self.findElement(locator)
        return ele

    def click_select_range(self):  #区域的下拉框的定位
        locator = (By.ID,"region_id")
        ele = self.findElement(locator)
        return ele


    def click_select_class(self):  #班级下拉框的定位
        locator = (By.NAME, "stuClass")
        ele = self.findElement(locator)
        return ele


    def click_select_direction(self):  #方向下拉框的定位
        locator = (By.NAME, "orientation")
        ele = self.findElement(locator)
        return ele


    def click_search_entry_information(self):   #搜索的定位
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/div/div/div/div[1]/button[1]")
        ele = self.findElement(locator)
        return ele



    #新增入职信息
    def click_add_join(self):    #点击新增
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/div/div/div/div[2]/div[2]/div[2]/table/tbody/tr[1]/td[8]/button[2]")
        ele = self.findElement(locator)
        return ele

    def get_joinposition(self):   #入职岗位
        locator = (By.XPATH, "/html/body/div[13]/div/div/div[2]/div/div/div/div/div/form/div[1]/select")
        ele = self.findElement(locator)
        return ele

    def get_joindata(self):  #点击了入职时间
        locator = (By.XPATH, "//*[@id='jdate']")
        ele = self.findElement(locator)
        return ele


    def get_detail_time(self):  #选择一个时间
        locator = (By.XPATH, "/html/body/div[11]/div[3]/table/tbody/tr[5]/td[4]")
        ele = self.findElement(locator)
        return ele

    def get_salary(self):
        locator = (By.XPATH, "//*[@id='jsalary']")
        ele = self.findElement(locator)
        return ele

    def get_select_company(self):   #点击选择公司的按钮
        locator = (By.XPATH, "/html/body/div[14]/div/div/div[2]/div/div/div/div/div/form/div[4]/div/button/span[1]")
        ele = self.findElement(locator)
        return ele

    def get_input(self):    #输入企业名称的框
        locator = (By.XPATH, "/html/body/div[14]/div/div/div[2]/div/div/div/div/div/form/div[4]/div/div/div/input")
        ele = self.findElement(locator)
        return ele

    def click_input(self):
        locator = (By.XPATH, "/html/body/div[14]/div/div/div[2]/div/div/div/div/div/form/div[4]/div/div/ul/li[1]/a/span[1]")
        ele = self.findElement(locator)
        return ele

    def click_save(self):       #保存按钮
        locator = (By.XPATH, "//*[@id='saveEditJBtn']")
        ele = self.findElement(locator)
        return ele

    def click_ensure(self):   #新增入职信息后的确定
        locator = (By.XPATH, "/html/body/div[14]/div/div/div[3]/button")
        ele = self.findElement(locator)
        return ele


    def search_table_join_company(self):
        locator = (By.CLASS_NAME, "table.table-hover.table-bordered.table-striped")
        ele = self.findElement(locator)
        return ele



#修改企业客户
    def input_name(self):    #修改企业客户页面的输入企业名称
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/input")
        ele = self.findElement(locator)
        return ele


    def click_sousuo(self):  #搜索按钮
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/button[1]")
        ele = self.findElement(locator)
        return ele

    def click_mod(self):    #修改按钮
        locator = (By.XPATH, "/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[9]/button")
        ele = self.findElement(locator)
        return ele

    def click_name(self):     #联系人
        locator = (By.XPATH, "//*[@id='entHeader']")
        ele = self.findElement(locator)
        return ele

    def save_mode(self):  #修改后保存
        locator = (By.XPATH, "/html/body/div[10]/div/div/div[3]/button")
        ele = self.findElement(locator)
        return ele

    def mod_ensure(self):#修改后的确定
        locator = (By.CLASS_NAME, "btn.btn-primary")
        eles = self.findElements(locator)
        return eles

    def get_table_mod(self):  #获取改后的那个表
        locator = (By.CLASS_NAME, "table.table-hover.table-bordered.table-striped")
        ele = self.findElement(locator)
        return ele


    def close_browser(self):   #关闭浏览器
        self.dr.close()










